/**
 * 节流
 */
let lock = false
export function throttle(fn: Function, delay = 300) {
  if (lock) {
    return
  }
  lock = true
  fn()
  setTimeout(() => {
    lock = false
  }, delay)
}

/**
 * 防抖
 */
let timeOut: any
export function debounce(fn: Function, delay = 300) {
  if (timeOut != null) {
    clearTimeout(timeOut)
    timeOut = null
  }
  timeOut = setTimeout(() => {
    fn()
  }, delay)
}
